
<!-- 列表 -->
<extend name="Public:layout" />
<block name="title"><{$authName}></block>

<block name="pluginCSS">
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Admin/plugins/select2/select2.css"/>
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Admin/plugins/select2/select2-metronic.css"/>
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Admin/plugins/bootstrap-fileinput/bootstrap-fileinput.css"/>
</block>
<block name="CSS"></block>

<block name="loadJS">

<script type="text/javascript" src="__PUBLIC__/Admin/plugins/select2/select2.min.js"></script>
<script src="__PUBLIC__/admin/scripts/layer/layer.js" type="text/javascript"></script>	
<script src="__PUBLIC__/Admin/plugins/bootstrap-fileinput/bootstrap-fileinput.js"></script>

</block>
<block name="setJS">
<script>
var ajaxUrl="<{:U('index')}>";

function callback(message,status)  {  
	if(status==1)  {  
		layer.msg(message, 
			{icon: 1,time: 2000},
			function(){
				location.href=ajaxUrl;
			}
		);   
	}  else{  
		layer.msg(message, 
			{icon: 2,time: 2000}
		);   
		
	}  
}  

</script>
</block>
<block name="initJS">
jQuery.validator.addMethod("regex",  
				function(value, element, params) {  
					var exp = new RegExp(params);  
					return exp.test(value);  
				}, "格式错误");
			validator =$('.form-horizontal').validate({
				errorElement: 'span', //default input error message container
				errorClass: 'help-block', // default input error message class
				focusInvalid: false, // do not focus the last invalid input
				rules: {
					loginName: {
						required: true,
						regex:"^\\w+$",
						remote:{  
							type: "post",  
							url: ajaxUrl,  
							data: {  
								key: function() {  
									return $("#loginName").val();  
								},
								id:function() {  
									return $("#id").val();  
								},
								ajax:"checkKey"
							},  
							dataType: "json"
						}  
					},

					userPhone: {
						required: true,
						number:true,
						remote:{  
							type: "post",  
							url: ajaxUrl,  
							data: {  
								key: function() {  
									return $("#userPhone").val();  
								},
								id:function() {  
									return $("#id").val();  
								},
								ajax:"checkKey"
							},  
							dataType: "json"
						}  
					},

					userEmail: {
						required: true,
						email:true,
						remote:{  
							type: "post",  
							url: ajaxUrl,  
							data: {  
								key: function() {  
									return $("#userEmail").val();  
								},
								id:function() {  
									return $("#id").val();  
								},
								ajax:"checkKey"
							},  
							dataType: "json"
						}  
					},
					loginPwd: {
						required: true,
						rangelength:[5,16] 
					},
					reLoginPwd: {
						required: true,
						rangelength:[5,16] ,
						equalTo:"#loginPwd"
					},
					
				},

				messages: {
					loginName: {
						required: "用户名不能为空。",
						regex:"用户名只能用数字字母下划线。",
						remote:"用户名已占用！"
					},
					userPhone: {
						required: "手机号不能为空。",
						number:"手机号格式不正确。",
						remote:"手机号已存在。"
					},
					userEmail: {
						required: "邮箱不能为空。",
						email:"邮箱格式不正确。",
						remote:"邮箱已存在。"
					},
					loginPwd: {
						required: "密码不能为空。",
						rangelength: "密码最少5个字符最多16个字符。"
					},
					reLoginPwd: {
						required: "密码不能为空。",
						rangelength: "密码最少5个字符最多16个字符。",
						equalTo:"请输入相同的密码！"
					}	
				},

				invalidHandler: function (event, validator) { //display error alert on form submit
					$('.alert-danger', $('.form-horizontal')).show();
				},

				highlight: function (element) { // hightlight error inputs
					$(element)
						.closest('.form-group').addClass('has-error'); // set error class to the control group
				},

				success: function (label) {
					label.closest('.form-group').removeClass('has-error');
					label.remove();
				},

				errorPlacement: function (error, element) {
					error.insertAfter(element.closest(':input'));
				},

				submitHandler: function (form) {
					form.submit();
					
				}
			});
			
			
			

			$('.form-horizontal input').keypress(function (e) {
				if (e.which == 13) {
					if ($('.form-horizontal').validate().form()) {
						$('.form-horizontal').submit();
					}
					return false;
				}
			});
			if($('#id').val()){
				$("#loginPwd").rules('remove','required');
			}else{
				$("#loginPwd").rules('add','required');
			}
</block>

<block name="pagetitle">增删改查</block>
<block name="page">
<div class="row">
	<div class="col-md-12">

		<div class="portlet">
			<div class="portlet-title">
				<div class="caption">
					<i class="fa <{$authIco}>"></i><{$authName}>
				</div>
				
				<div class="actions">
					<a class="btn default green-stripe" id="table_manager_new" data-toggle="modal" href="javascript:history.back()">
						<i class="fa fa-reply"></i>
						<span class="hidden-480">返回</span>
					</a>
				</div>
				
			</div>
			<div class="portlet-body">
				<form class="form-horizontal" action="<{:U('index')}>" method="post" target="ajax" enctype="multipart/form-data">
					<iframe style="display:none" name='ajax' id="ajax" ></iframe>
					<input type='hidden' id='noAjax' name="noAjax" value='editUsers'/>
        			<input type='hidden' id='id' name="id" value='<{$object.userId}>'/>
        			<div class="form-body">
       <div class="col-md-6">
			        <div class="form-group">
						<label class="col-md-4 control-label" for="loginName">账号</label>
						<div class="col-md-8">
							<input type='text' id='loginName' name='loginName' class="form-control" value='<{$object.loginName}>'/>
						</div>
					</div>
		           <div class="form-group">
						<label class="col-md-4 control-label" for="loginPwd">密码</label>
						<div class="col-md-8">
			             <input type='password' id='loginPwd' name="loginPwd" class="form-control" value=''/>
			             <if condition="$object['userId'] !=0 ">(为空则说明不修改密码)</if></div>
					</div>
			           <div class="form-group">
						<label class="col-md-4 control-label" for="userName">用户名</label>
						<div class="col-md-8">
			             <input type='text' id='userName' name="userName" class="form-control" value='<{$object.userName}>' />
			             </div>
					</div>
		           <div class="form-group">
					<label class="col-md-4 control-label" for="userSex">性别</label>
					<div class="col-md-8">
					<div class="radio-list">
		             <label class="radio-inline">
		             <input type='radio' id='userSex1' name='userSex' <if condition="$object.userSex eq 1">checked</if> value='1'/> 男
		             </label>
		             <label class="radio-inline">
		             <input type='radio' id='userSex2' name='userSex' <if condition="$object.userSex eq 2">checked</if> value='2'/> 女
		             </label>
		             <label class="radio-inline">
		             <input type='radio' id='userSex0' name='userSex' <if condition="$object.userSex eq 0">checked</if> value='0'/> 保密
		             </label>
		             </div>
		             </div>
				</div>
		           <div class="form-group">
					<label class="col-md-4 control-label" for="userPhone">手机号码</label>
					<div class="col-md-8">
		             <input type='text' id='userPhone' name='userPhone' class="form-control" value='<{$object.userPhone}>' maxLength='11'/>
		             </div>
				</div>
		           <div class="form-group">
					<label class="col-md-4 control-label" for="userEmail">电子邮箱</label>
					<div class="col-md-8">
		             <input type='text' id='userEmail' name='userEmail' class="form-control"  value='<{$object.userEmail}>' maxLength='25'/>
		            </div>
				</div>

	</div>
	<div class="col-md-6">
				<div class="form-group">
										<label>头像</label>
										<div>
											<div class="fileinput fileinput-new" data-provides="fileinput">
												<div class="fileinput-new thumbnail" style="width: 200px; height: 150px;">
													<if condition="$object['userPhoto'] =='' ">
													<img src="__UPLOAD__/avatar/avatar_m.jpg"/>
													<else/>
													<img src="__UPLOAD__/<{$object['userPhoto']|str_replace='.','_m.',###}>">
													</if>
												</div>
												<div class="fileinput-preview fileinput-exists thumbnail" style="max-width: 200px; max-height: 150px;">
												</div>
												<div>
													<span class="btn default btn-file">
														<span class="fileinput-new">
															 选择图片
														</span>
														<span class="fileinput-exists">
															 更改图片
														</span>
														<input type="file" name="userPhoto" id="userPhoto">
													</span>
													<a href="#" class="btn default fileinput-exists" data-dismiss="fileinput">
														 删除图片
													</a>
												</div>
											</div>
										</div>
									</div>

									<div class="form-group">
							<label class="col-md-2 control-label" for="userStatus">会员状态</label>
							<div class="col-md-6">
								<div class="radio-list">
															
						             <label class="radio-inline">
						             <input type='radio' id='userStatus1' value='1' name='userStatus' <if condition="($object.userStatus eq 1) or $object.userId eq 0">checked</if>/> 启用
						             </label>
						             <label class="radio-inline">
						             <input type='radio' id='userStatus0' value='0' name='userStatus' <if condition="$object.userStatus eq 0">checked</if>/> 停用
						             </label>
				             	</div>
				             </div>
						</div>	

	</div>
	<!-- </div> -->
	<div class="col-md-12">
			
			<div class="clearfix"></div>
		           <div class="form-group">
					<label class="col-md-2 control-label" for="userQQ">QQ</label>
					<div class="col-md-6">
		             <input type='text' id='userQQ' name="userQQ" class="form-control"  value='<{$object.userQQ}>'/>
		             </div>
				</div>
			
		           <div class="form-group">
					<label class="col-md-2 control-label" for="userScore">会员积分</label>
					<div class="col-md-6">
		             <input type='text' id='userScore' name="userScore" class="form-control"  value='<{$object.userScore}>' />
		             </div>
				</div>
		           <div class="form-group">
					<label class="col-md-2 control-label" for="userTotalScore">会员历史积分</label>
					<div class="col-md-6">
		             <input type='text' id='userTotalScore' name="userTotalScore" class="form-control"  value='<{$object.userTotalScore}>'/>
		             </div>
				
          </div>   						
            
           			<div class="form-group fluid">
		                <div class="col-md-offset-2 col-md-9">
		                  <button type="submit" class="btn blue">保存</button>
		                  <button type="reset" class="btn default">取消</button>
		                </div>
		              </div>


		</div>
       </form>
				
				</div>
		</div>
	</div>
</div>
</block>